package org.rockyang.shardingjdbc.mybatisplus.common.keygenerator;

import lombok.extern.slf4j.Slf4j;
import org.apache.shardingsphere.spi.keygen.ShardingKeyGenerator;
import org.rockyang.shardingjdbc.mybatisplus.common.utils.Snowflake;

import java.util.Properties;

@Slf4j
public class MyKeyGenerator implements ShardingKeyGenerator {

    @Override
    public Comparable<?> generateKey() {
        long id = Snowflake.getNextId();
        log.info("sharding-jdbc自定义生成id:"+id);
        return id;
    }

    /**
     *
     * @return
     */
    @Override
    public String getType() {
        return "MyKeyGenerator";
    }

    @Override
    public Properties getProperties() {
        return null;
    }

    @Override
    public void setProperties(Properties properties) {

    }
}